package com.nineyang.bean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.List;
/*
 将配置文件属性绑定到bean
 1.将bean纳入IOC容器管理
    纳入容器管理有四种方法：
        1.添加注解@Configuration
        2.添加注解@Component
        3.在springboot入口程序上添加注解@EnableConfigurationProperties(User.class)
        4.在springboot入口程序上添加注解@ConfigurationPropertiesScan(basePackages="com.nineyang.bean")
 2.添加注解@ConfigurationProperties
 3.属性字段名称和配置文件字段一一对应
 4.为属性添加set方法
 */
//@Configuration
//@Component
@ConfigurationProperties(prefix = "tjy")
public class User {

    private String name;
    private int age;
    private Address address;
    private List<String> emails;

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", address=" + address +
                ", emails=" + emails +
                '}';
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public void setEmails(List<String> emails) {
        this.emails = emails;
    }
}
